<template>
  <!--
    输入框:
      type: 'input'
      prop:  绑定属性
      label: 标题
      itemType:     原生 input 的 type（text、number、password、textarea等，默认text）
      placeholder:  输入框占位文本，默认‘请输入’+label
      width:        输入框宽度
      readonly:  是否只读，默认false
      disabled:  是否禁用，默认false
      clearable: 是否可清空，默认true
  -->
  <el-input
    v-model="currentData"
    :type="itemType"
    :placeholder="(booleanFun(disabled)||booleanFun(readonly))?'':placeholder || `请输入${label}`"
    :disabled="booleanFun(disabled)"
    :readonly="booleanFun(readonly)"
    :clearable="clearable"
    :style="{width}"
    :max="max"
    :min="min"
    :show-password="itemType === 'password'"
    :autosize="{minRows: 3, maxRows: 10000}"
    size="mini"
  />

</template>

<script>
import {booleanFun, currentData} from '@/components/FlyElement/common'

export default {
  name: 'AInput',
  props: {
    prop: {
      type: String,
      required: true
    },
    label: {
      type: String,
      required: true
    },
    data: {
      type: String | Number
    },
    itemType: {
      type: String,
      default: 'text'
    },
    placeholder: {
      type: String
    },
    width: {
      type: String,
      default: '100%'
    },
    readonly: {
      type: Boolean | Function,
      default: false
    },
    disabled: {
      type: Boolean | Function,
      default: false
    },
    clearable: {
      type: Boolean
    },
    min: {
      type: Number
    },
    max: {
      type: Number
    },
    step: {
      type: Number
    },
  },
  computed: {
    currentData
  },
  methods: {
    booleanFun
  }
}
</script>
